package com.bdqn.t350.ch04mybatisplus.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    SessionInterceptor sessionInterceptor;

    private String[] excludePathPatterns;

    public void addInterceptors(InterceptorRegistry registry) {
        String[] pathPatterns = {"/**"}; //拦截路径规则
        String[] excludePathPatterns = {"/login", "/regist", "/statics/**"}; //
        registry.addInterceptor(sessionInterceptor) //注册拦截器
                .addPathPatterns(pathPatterns)//添加路径规则
                .excludePathPatterns(excludePathPatterns); //添加排除路径规则
    }
}
